//导入常用JS writeJS('js/jquery-2.2.4.min.js'); writeJS('js/date-time/bootstrap-datepicker.min.js'); writeJS('js/date-time/bootstrap-timepicker.min.js'); writeJS('My97DatePicker/WdatePicker.js'); writeJS('js/master.js'); writeJS('js/jquery.page.js'); writeJS('js/jquery.cookie.js'); writeJS('../js/base_path.js'); writeJS('js/xm.js'); //判断登录 writeJS('js/xcConfirm.js'); writeCSS('css/xcConfirm.css'); //导入CSS // 导入JS文件 function writeJS(jsStr) { var cstr = ''; document.write(cstr); } // 导入CSS function writeCSS(cssStr) { var cstr = ''; document.write(cstr); } var base_api = "http://127.0.0.1/ZZCX_HT_2.0/st-ht/HTcontrol.php"; base_api = "http://temp.zhizhuchuxing.com/zz-jd/st-ht/HTcontrol.php"; base_api = "../st-ht/HTcontrol.php"; base_api = "/zz-jd/st-ht/HTcontrol.php"; var _principal = [1, 33, 35, 160]; // 打印日志 function ZZLog() { var isLog = true; //是否打印 var isSign = false; //是否签名 if (isLog) { if (isSign) { //如果要加前缀 var args = Array.prototype.slice.call(arguments); args.unshift('[ZZCX:DeBug:Log]'); console.log.apply(console, args); } else { console.log.apply(console, arguments); } } } //需要成功回调的弹出框 function ZZAlertInfo(info, callok) { window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.info, { onOk: function () { if (callok) { callok(); } } }); } //确认框(提示信息,成功回调,取消回调,关闭回调) function ZZConfirm(info, callok, callcancel, callclose) { window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.confirm, { onOk: function () { if (callok) { callok(); } }, onCancel: function () { if (callcancel) { callcancel(); } }, onClose: function () { if (callclose) { callclose(); } } }) } //输入框(输入的信息,成功回调,关闭的回调) function ZZInput(info, callok, callclose) { window.wxc.xcConfirm(info, window.wxc.xcConfirm.typeEnum.input, { onOk: function (ok) { if (callok) { callok(ok); } }, onClose: function (close) { if (callclose) { callclose(close); } } }); } //设置字符串类型的本地缓存 function setStorage(objName, objValue) { var sto = window.localStorage; if (sto) sto.setItem(objName, objValue); } //读取字符串类型的本地缓存 function getStorage(objName) { var ret = ''; var sto = window.localStorage; if (sto) ret = sto.getItem(objName); return ret; } //清除本地缓存,如没指定名称则为清空所有缓存 function clearStorage(objName) { var sto = window.localStorage; if (sto) { if (objName) sto.removeItem(objName); else sto.clear(); } } //设置Json类型的本地缓存 function setStorJson(objName, json) { if (json) setStorage(objName, JSON.stringify(json)); } //读取Json类型的本地缓存 function getStorJson(objName) { var ret = null; var str = getStorage(objName); if (str) ret = JSON.parse(str); return ret; } //js判断一个日期是星期几 传入 年/月/日 function getWeekDay(day) { var a = new Array("日", "一", "二", "三", "四", "五", "六"); var week = new Date(day).getDay(); var str = "星期" + a[week]; return str; } //获取前一天日期 function before(d) { d = new Date(d); d = +d - 10006060 / 3 * 24; d = new Date(d); //return d; //格式化 var year = ";" + d.getFullYear() + ";"; var month = ";" + (d.getMonth() + 0 + 1) + ";"; var day = ";" + d.getDate() + ";"; if (year.length < 4) { year = "0" + year; } if (month.length < 4) { month = "0" + month; } if (day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); return datestr; // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate(); } // 获取指定日期的前后几天 function getDateByDay(addDayCount, curDate) { var d = new Date(curDate); d.setDate(d.getDate() + addDayCount);//获取AddDayCount天后的日期 //格式化 var year = ";" + d.getFullYear() + ";"; var month = ";" + (d.getMonth() + 0 + 1) + ";"; var day = ";" + d.getDate() + ";"; if (year.length < 4) { year = "0" + year; } if (month.length < 4) { month = "0" + month; } if (day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); return datestr; } //获取后一天日期 function after(d) { d = new Date(d); d = +d + 10006060 / 3 * 24; d = new Date(d); //return d; //格式化 var year = ";" + d.getFullYear() + ";"; var month = ";" + (d.getMonth() + 0 + 1) + ";"; var day = ";" + d.getDate() + ";"; if (year.length < 4) { year = "0" + year; } if (month.length < 4) { month = "0" + month; } if (day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); return datestr; // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate(); } // 从URL上获得参数 function getPar(par) { //获取当前URL var local_url = document.location.href; local_url = decodeURI(local_url); //获取要取得的get参数位置 var get = local_url.indexOf(par + "="); if (get == -1) { return ""; } //截取字符串 var get_par = local_url.slice(par.length + get + 1); //判断截取后的字符串是否还有其他get参数 var nextPar = get_par.indexOf("&"); if (nextPar != -1) { get_par = get_par.slice(0, nextPar); } return get_par; } //得到时间组合 function getDateTime(nTypeFlag, DateTime) { var tNowTime; if(typeof DateTime == "undefined") tNowTime = new Date(); else tNowTime = DateTime; var myYear = ';' + tNowTime.getFullYear() + ';'; var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';'; var myDay = ';' + tNowTime.getDate() + ';'; var myHour = ';' + tNowTime.getHours() + ';'; var myMinu = ';' + tNowTime.getMinutes() + ';'; var mySecond = ';' + tNowTime.getSeconds() + ';'; if (myMonth.length < 4) myMonth = '0' + myMonth; if (myDay.length < 4) myDay = '0' + myDay; if (myHour.length < 4) myHour = '0' + myHour; if (myMinu.length < 4) myMinu = '0' + myMinu; if (mySecond.length < 4) mySecond = '0' + mySecond; var cNewTimeStr; //alert(tNowTime); switch (nTypeFlag + 1 - 1) { case 0: cNewTimeStr = myYear + '-' + myMonth + '-' + myDay; break; case 1: cNewTimeStr = myYear + myMonth + myDay; break; case 2: cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond; break; case 3: cNewTimeStr = myHour + myMinu + mySecond; break; case 4: cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond; break; case 5: cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日'; break; case 6: cNewTimeStr = myYear; break; case 7: cNewTimeStr = myYear + '-' + myMonth; break; case 8: //得到上一个月的今天 var date = getDateTime(0); var arr = date.split('-'); var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var day = arr[2]; //获取当前日期的日 var days = new Date(year, month, 0); days = days.getDate(); //获取当前日期中月的天数 var year2 = year; var month2 = parseInt(month) - 1; if (month2 == 0) { year2 = parseInt(year2) - 1; month2 = 12; } var day2 = day; var days2 = new Date(year2, month2, 0); days2 = days2.getDate(); if (day2 > days2) { day2 = days2; } if (month2 < 10) { month2 = '0' + month2; } cNewTimeStr = year2 + '-' + month2 + '-' + day2; break; case 9: //得到下一个月的今天 var date = getDateTime(0); var arr = date.split('-'); var year = arr[0]; //获取当前日期的年份 var month = arr[1]; //获取当前日期的月份 var day = arr[2]; //获取当前日期的日 var days = new Date(year, month, 0); days = days.getDate(); //获取当前日期中的月的天数 var year2 = year; var month2 = parseInt(month) + 1; if (month2 == 13) { year2 = parseInt(year2) + 1; month2 = 1; } var day2 = day; var days2 = new Date(year2, month2, 0); days2 = days2.getDate(); if (day2 > days2) { day2 = days2; } if (month2 < 10) { month2 = '0' + month2; } var t2 = year2 + '-' + month2 + '-' + day2; return t2; break; case 10: //昨日日期 //获取前一天日期 return before(getDateTime(0)); function before(d) { d = new Date(d); d = +d - 10006060 / 3 * 24; d = new Date(d); //return d; //格式化 var year = ";" + d.getFullYear() + ";"; var month = ";" + (d.getMonth() + 0 + 1) + ";"; var day = ";" + d.getDate() + ";"; if (year.length < 4) { year = "0" + year; } if (month.length < 4) { month = "0" + month; } if (day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); return datestr; // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate(); } break; case 11: //明日日期 //获取后一天日期 return after(getDateTime(0)); function after(d) { d = new Date(d); d = +d + 10006060 / 3 * 24; d = new Date(d); //return d; //格式化 var year = ";" + d.getFullYear() + ";"; var month = ";" + (d.getMonth() + 0 + 1) + ";"; var day = ";" + d.getDate() + ";"; if (year.length < 4) { year = "0" + year; } if (month.length < 4) { month = "0" + month; } if (day.length < 4) { day = "0" + day; } var datestr = year + "-" + month + "-" + day; datestr = datestr.replace(/;/g, ""); return datestr; // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate(); } break; case 12://本周起始日期 return getWeekStartDate() function getWeekStartDate() { var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getYear(); //当前年 nowYear += (nowYear < 2000) ? 1900 : 0; // var lastMonthDate = new Date(); //上月日期 lastMonthDate.setDate(1); lastMonthDate.setMonth(lastMonthDate.getMonth() - 1); var lastYear = lastMonthDate.getYear(); var lastMonth = lastMonthDate.getMonth(); var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek); return formatDate(weekStartDate); } break; case 13://本周结束日期 return getWeekEndDate() function getWeekEndDate() { var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getYear(); //当前年 nowYear += (nowYear < 2000) ? 1900 : 0; // var lastMonthDate = new Date(); //上月日期 lastMonthDate.setDate(1); lastMonthDate.setMonth(lastMonthDate.getMonth() - 1); var lastYear = lastMonthDate.getYear(); var lastMonth = lastMonthDate.getMonth(); var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek)); return formatDate(weekEndDate); } break; case 14://本月开始日期 return getMonthStartDate() function getMonthStartDate() { var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getYear(); //当前年 nowYear += (nowYear < 2000) ? 1900 : 0; // var lastMonthDate = new Date(); //上月日期 lastMonthDate.setDate(1); lastMonthDate.setMonth(lastMonthDate.getMonth() - 1); var lastYear = lastMonthDate.getYear(); var lastMonth = lastMonthDate.getMonth(); var monthStartDate = new Date(nowYear, nowMonth, 1); return formatDate(monthStartDate); } break; case 15://本月结束日期 return getMonthEndDate(); function getMonthEndDate() { var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getYear(); //当前年 nowYear += (nowYear < 2000) ? 1900 : 0; // var lastMonthDate = new Date(); //上月日期 lastMonthDate.setDate(1); lastMonthDate.setMonth(lastMonthDate.getMonth() - 1); var lastYear = lastMonthDate.getYear(); var lastMonth = lastMonthDate.getMonth(); //获得某月的天数 function getMonthDays(myMonth) { var monthStartDate = new Date(nowYear, myMonth, 1); var monthEndDate = new Date(nowYear, myMonth + 1, 1); var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24); return days; } var monthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth)); return formatDate(monthEndDate); } break; default: cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond; break; } cNewTimeStr = cNewTimeStr.replace(/;/g, ""); return cNewTimeStr; } //case 12,13的规整函数 function formatDate(date) { var myyear = date.getFullYear(); var mymonth = date.getMonth() + 1; var myweekday = date.getDate(); if (mymonth < 10) { mymonth = "0" + mymonth; } if (myweekday < 10) { myweekday = "0" + myweekday; } return (myyear + "-" + mymonth + "-" + myweekday); } //html存入json function setJsonHtml(data) { if (typeof(data) == "object") { var jsonArrayFinal = JSON.stringify(data); jsonArrayFinal = jsonArrayFinal.replace(/ /g, ''); jsonArrayFinal = jsonArrayFinal.replace(/"/g, '"'); return jsonArrayFinal; } } //取出html存入的json function getJsonHtml(data) { if (data && data.indexOf('[') == -1) { var data_info = JSON.parse(data); return data_info; }else{ return 0 } } function getCookie(c_name) { var i, x, y, ARRcookies = document.cookie.split(";"); for (i = 0; i < ARRcookies.length; i++) { x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); x = x.replace(/^\s+|\s+$/g, ""); if (x == c_name) { return unescape(y); } } } // function setCookie(c_name, value, exdays) { // var exdate = new Date(); // exdate.setDate(exdate.getDate() + exdays); // var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()); // document.cookie = c_name + "=" + c_value; // } //修改订单需要记录修改详细内容,保存好原数据 function initOldData(order_data) { // var _old_data = { // order_id: '', // org_id: '', // org_num: '', // room_list: '', // cus_list: '', // checkin_time: '', // if_cancel: '', // benefit: '', // total_commission: '' // }; var order_p = order_data.hotel_order_detail[0], order_c = order_data.hotel_child_order_detail; var amount = 0; // var cus_list = "{" + order_p.customer_name + "," + order_p.customer_mobile + "," + order_p.customer_memo + "}"; _old_data['contact'] = order_p.customer_name; _old_data['mobile'] = order_p.customer_mobile; _old_data['memo'] = order_p.customer_memo; _old_data['org_id'] = org_id; _old_data['org_num'] = order_p.outside_order_no; // _old_data['org_name'] = $("#org_id option[value='"+ org_id.toString()+ "']").html() _old_data['start_date'] = order_p.start_date; // _old_data['end_date'] = order_p.end_date; //间夜数 var count = 0; $.each(order_c, function (key, order) { count += parseInt(order.total); amount += order['order_price'] * order['total']; }) _old_data['total'] = count; _old_data['amount'] = amount; } //对比数据,返回需要记录的字段 function compareOldData(new_order_data) { var list = []; $.each(_old_data, function (key, item) { if ( key != 'amount' && item != new_order_data[key]) { //备注去除 if (key == 'org_id') {// 修改渠道商 var b = $("#org_id option[value='" + new_order_data[key] + "']").html() var a = $("#org_id option[value='" + item + "']").html(); list.push({'name': key, 'old_val': a, 'new_val': b}); } else list.push({'name': key, 'old_val': item, 'new_val': new_order_data[key]}); } }) return list; } function removeNote(obj, flag) { if(flag){ ZZConfirm('确认要删除备注?', function () { $(obj).closest('.note').remove(); }) }else{ $(obj).closest('.note').remove(); } } //日期获取上周 function getLastWeek(){ var today = new Date(); var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 7); return lastWeek ; } //权限控制 function playPermission(){ var urlapi = base_api; var _hotel_id = getPar('hotel_id'), user_id = getCookie('user_id'); var param = { type: "hotel_HotelList", hotel_id: _hotel_id, op: "getDetail" }; ZZLog(urlapi + JSON.stringify(param)); $.ajax({ url: urlapi, data: param, type: "post", dataType: "json", success: function (res_data) { ZZLog(res_data); if (res_data['code'] != "0") { alert(res_data['info']); } else { var tmp = [], temp; temp = res_data['rowset'][0]['PRINCIPAL']; if(typeof temp == 'string') tmp = temp.split(','); var principal = $.merge(_principal, tmp); if($.inArray(user_id, principal.toString().split(',')) < 0){ // $(".permission-display").hide(); // $(".permission td.bday").unbind('click'); // $(".permission td.cday").unbind('click'); // $(".permission td.change").unbind('click'); // $(".permission td.change").attr('onclick',''); // $(".permission td img").attr('onclick',''); } } }, error: function (error) { alert('system ajax http error'); ZZLog(error); } }) } function all_sum() { all_yongj = 0; all_jiesuan = 0; all_profit = 0; var all_yongj1= 0; var all_jiesuan1 = 0; var all_profit1 = 0; $('.yongj_sum').each(function () { all_yongj += parseFloat($(this).text()) }); if (isNaN(all_yongj)) { all_yongj = 0 } $('.jiesuan_sum').each(function () { all_jiesuan += parseFloat($(this).text()) }); if (isNaN(all_jiesuan)) { all_jiesuan = 0 } $('.benefit_sum').each(function () { all_profit += parseFloat($(this).text()) }); if (isNaN(all_profit)) { all_profit = 0 } all_yongj1 = all_yongj.toFixed(2); all_jiesuan1 = all_jiesuan.toFixed(2); all_profit1 = all_profit.toFixed(2); $('#all_yongj').text(all_yongj1 + '元'); $('#all_jiesuan').text(all_jiesuan1 + '元'); $('#all_profit').text(all_profit1 + '元'); } /** * 加载时尽量考虑什么时候关闭,否则15秒后自动关闭 */ function loading(time) { var newDiv = '
' + '
'; if(typeof $("#screen-cover") != 'undefined') $("#screen-cover").remove(); $("") .attr({ rel: "stylesheet", type: "text/css", href: "/css/loader.css" }) .appendTo("head"); $("html").append(newDiv); $("#screen-cover").css('padding-top', $(window).height() / 2 - 55); // if(typeof time == 'undefined') // time = 15000; // setTimeout('closeLoading()',time); } function closeLoading() { if($("#screen-cover").length > 0) $("#screen-cover").remove(); }